<template>
  <div>
    <img
      class="banner"
      src="https://akk.028wkf.cn/kdb-weapp-img/wgsj.png"
      mode="scaleToFill"
    >
    <div class="inputDiv">
      <input
        class="topInput"
        type="text"
        placeholder="输入您的姓名"
        v-model="form.name"
      >
      <input
        class="topInput"
        type="text"
        placeholder="输入您的身份证号"
        v-model="form.idCard"
      >
    </div>

    <button class="btn" @click="applyForClick">立即申请</button>
  </div>
</template>

<script>
import {} from '@/utils'
import { ADD_SHOP_CHANGE_APPLY_API } from '@/api'

export default {
  components: {},
  props: {},
  data () {
    return {
      form: {
        name: '',
        idCard: ''
      },
      hint: {
        name: '请输入姓名',
        idCard: '请输入身份证号码'
      }
    }
  },
  computed: {
    account () {
      return this.$store.state.account
    }
  },
  watch: {},
  created () {},
  mounted () {},
  onShow () {},
  methods: {
    applyForClick () {
      const vm = this
      for (let key in vm.form) {
        if (!vm.form[key]) {
          vm.$toast(vm.hint[key])
          return false
        }
      }
      vm._addShopChangeApplyApi()
    },
    _addShopChangeApplyApi () {
      const vm = this
      let params = { ...vm.form }
      params.shopId = vm.$cookie.get('account').shopId
      params.shopIdentity = 'VIRTUAL'
      ADD_SHOP_CHANGE_APPLY_API(params)
        .then(r => {
          if (r.data.code === '0') {
            wx.showModal({
              title: '资料提交成功',
              content:
                '我们会在1-3个工作日内处理您的申请若有问题请致电400-888-5115',
              showCancel: false,
              confirmText: '确定',
              confirmColor: '#5d93fd',
              success: function (res) {
                if (res.confirm) {
                  vm.$router.go(-1)
                }
              },
              fail: function (err) {
                console.error(err)
              }
            })
          } else {
            vm.$toast(r.data.message)
          }
        })
        .catch(e => {
          console.error(e)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'static/styles/color.scss';
.banner {
  width: 100%;
  height: 130px;
}
.inputDiv {
  width: 95%;
  margin: auto;
  .topInput {
    font-size: 14px;
    width: 100%;
    border-bottom: 1px solid #e7e7e7;
    height: 50px;
    line-height: 50px;
  }
}
.btn {
  width: 88%;
  margin: 30px auto 40px;
  height: 40px;
  border-radius: 25px;
  color: #fff;
  background: #5c94fc;
  font-size: 14px;
  line-height: 40px;
}
</style>
